<%@LANGUAGE="JAVASCRIPT" CODEPAGE="65001"%>
<!-- #include file = "../core.asp" -->
<%
	var _system = $('system');
	var _action = _system.read('action');
	var _id = _system.read('id');
	
	var _database = $('database');
	_database.path = '../database/#database.mdb';
	
	switch (_action) {
		case 'show':
			_show();
			break;
		case 'delete':
			_delete();
			break;
		default:
			_main();
			break;
	}
%>


<%
	function _show() {
		_header();
		var _guestbook = _database.query('select [Title], [Name], [Telephone], [Email], [Content] from [Guestbook] where [Id] = ' + _id);
%>
	<tr>
    	<th colspan="2" class="border"><strong>留言管理 - 查看留言信息</strong></th>
    </tr>
    <tr>
   	  	<td valign="top">
                <table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#999999">
                    <tr>
                        <td bgcolor="#eeeeee" height="24" width="80">&nbsp;<strong>标题 
 </strong></td>
                        <td bgcolor="#eeeeee">&nbsp;<% =_guestbook[0].title %></td>
                     </tr>
                    <tr>
                        <td bgcolor="#eeeeee" height="24" width="80">&nbsp;<strong>姓名</strong></td>
                        <td bgcolor="#eeeeee">&nbsp;<% =_guestbook[0].name %></td>
                    </tr>
                    <tr>
                        <td bgcolor="#eeeeee" height="24" width="80">&nbsp;<strong>电话</strong></td>
                        <td bgcolor="#eeeeee">&nbsp;<% =_guestbook[0].telephone %></td>
                    </tr>
                    <tr>
                        <td bgcolor="#eeeeee" height="24" width="80">&nbsp;<strong>电子邮箱</strong></td>
                        <td bgcolor="#eeeeee">&nbsp;<% =_guestbook[0].email %></td>
                    </tr>
                    <tr>
                        <td bgcolor="#eeeeee" height="24" width="80">&nbsp;<strong>内容</strong></td>
                        <td bgcolor="#eeeeee">&nbsp;<% =_guestbook[0].content %></td>
                    </tr>
                    <tr>
                        <td bgcolor="#eeeeee" height="24" colspan="2"><input type="button" name="return" id="return" value="返回" class="button" onClick="javascript: history.go(-1);" /></td>
                    </tr>
                </table>
        </td>
    </tr>
<%
		_footer();
	}
%>

<%
	function _delete() {
		var _sql = 'delete * from [Guestbook] where [Id] = ' + _id;
		var _url = 'guestbook.asp';

		_database.execute(_sql);
		_system.redirect(_url);
	}
%>

<%
	function _main() {
		_header();
		var _index = parseInt(_system.read('page')) || 1;
		var _guestbooks = _database.query('[Id], [Title], [Name]', '[Guestbook]', '', '[Id] desc', 0, _index, 20);
%>
	<tr>
    	<th colspan="2" class="border"><strong>留言信息管理</strong></th>
    </tr>
    <tr>
   	  	<td valign="top">
        	<table width="100%" border="0" cellpadding="0" cellspacing="1" bgcolor="#999999">
				<tr>
                    <td bgcolor="#eeeeee" height="24" colspan="2">&nbsp;<strong>留言信息列表</strong></td>
                    <td bgcolor="#eeeeee" colspan="2" width="81">&nbsp;</td>
				</tr>
<%
			for (var _index = 0; _index < _guestbooks.length; _index++) {
%>
                <tr>
                    <td bgcolor="#eeeeee" height="24">&nbsp;<% =_guestbooks[_index].title %></td>
                    <td bgcolor="#eeeeee" width="80">&nbsp;<% =_guestbooks[_index].name %></td>
                    <td bgcolor="#eeeeee" width="40">&nbsp;<a href="?action=show&id=<% =_guestbooks[_index].id %>">查看</a></td>
                    <td bgcolor="#eeeeee" width="40">&nbsp;<a href="?action=delete&id=<% =_guestbooks[_index].id %>" onClick="return confirm('你确定要删除么?');">删除</a></td>
				</tr>
<%
			}
			if (_guestbooks.length == 0) {
%>
				<tr>
					<td colspan="4" bgcolor="#F4F4F4" height="24">&nbsp;暂时没有留言信息！</td>
				</tr>
<%
			}
			else {
				var _index = parseInt(_system.read('page')) || 1;
				var _queryString = _system.query;
				var _page = '';
				
				if (_queryString == '' || _queryString.indexOf('page') == 0) {
					_page = '<a href="?' + _queryString.replace(/page=\d+/gi, '') + 'page=' + (_index - 1 > 0 ? _index - 1 : 1) + '">上一页</a>&nbsp;&nbsp;<a href="?' + _queryString.replace(/page=\d+/gi, '') + 'page=' + (_index + 1 < _database.pageCount ? _index + 1 : _database.pageCount) + '">下一页</a>&nbsp;&nbsp;共' + _database.pageCount + '页';
				}
				else {
					_page = '<a href="?' + _queryString.replace(/&page=\d+/gi, '') + '&page=' + (_index - 1 > 0 ? _index - 1 : 1) + '">上一页</a>&nbsp;&nbsp;<a href="?' + _queryString.replace(/&page=\d+/gi, '') + '&page=' + (_index + 1 < _database.pageCount ? _index + 1 : _database.pageCount) + '">下一页</a>&nbsp;&nbsp;共' + _database.pageCount + '页';
				}
%>
				<tr>
					<td colspan="4" bgcolor="#F4F4F4" height="24">&nbsp;<% =_page %></td>
				</tr>
<%
			}
%>
            </table>
        </td>
    </tr>
<%
		_footer();
	}
%>

<%
//********************************************************************************
%>
<%
	function _header() {
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>BestWeb Content System</title>
<script type="text/javascript" src="../script/jquery.js"></script>
<script type="text/javascript" src="script/validate.js"></script>
<link rel="stylesheet" type="text/css" href="style/content.css" />
</head>

<body>
<table width="100%" border="0" cellspacing="5" cellpadding="0" class="content">
<%
	}
%>

<%
	function _footer() {
%>
</table>
</body>
</html>
<%
	}
%>
<%
//********************************************************************************
%>